<template>
  <div class="project1List">
    <cheader :pageIndex="project"></cheader>
    <!-- <div class="banner" :style="{backgroundColor: bannerBg[project]}"> -->
    <div class="banner">
      <img src="@/common/img/bg.png" alt="" class="bg">
      <div class="color" :style="{backgroundImage: 'linear-gradient('+ bannerBg[project] + ','+ bannerBg[project] +', #fff)'}"></div>
      <div class="content">
        <div class="p1-title">
          <div class="tWrap">
            <div class="t">
              <!-- <img src="@/common/img/ball1.png" alt=""> -->
              <img :src="ball" alt="">
              <!-- <img :src="'../../common/img/common/ball'+ (parseInt(project)+1) +'.png'" alt=""> -->
              <h2>“{{titleArr[project][blc].title1}}”</h2>
              <i></i>
            </div>
          </div>
          <div class="bWrap">
            <div class="b">
              <h3>{{titleArr[project][blc].title2}}</h3>
              <i></i>
            </div>
          </div>
        </div>
        <!-- <span class="goProject" @click="goProject">返回专题页 ></span> -->
      </div>
    </div>
    <!-- <div class="tab" v-if="schoolArr.length>0">
      <ul>
        <li @click="chooseSchool" :data-lid='0' :class="[schoolActive ==0?'active':'']">全部</li>
        <li v-for="(item, index) in schoolArr" :key="item.id" :data-lid='item.id' :data-index='index' @click="chooseSchool" :class="[schoolActive == index+1?'active':'']">{{item.title}}</li>
      </ul>
    </div> -->
    <div class="list" ref="count">
      <ul v-if="dataArr.length">
        <li v-for="item in dataArr" :key="item.id" @click ="jump" :data-did="item.id">
          <div class="t" :style="{backgroundImage: 'url('+ item.lcover +')' }"  :data-did="item.id">
            <!-- <span class="cover" :data-did="item.id" v-if="item.ctype != 1">
              <h3 :data-did="item.id">{{item.title.length>8?item.title.substring(0, 8)+'...' : item.title}}</h3>
            </span> -->
            <span class="videoCover" :data-did="item.id" v-if="item.ctype == 1">
              <img src="@/common/img/play.png" alt="" class="icon" :data-did="item.id">
            </span>
          </div>
          <div class="b" v-if="item.title" :data-did="item.id">
            <!-- <h4>{{item.description.length>8?item.description.substring(0, 8)+'...' : item.description}}</h4> -->
            <h4  :data-did="item.id" v-html="item.title.length>8?item.title.substring(0, 8)+'...' : item.title"></h4>
          </div>
        </li>
        <li class="itemempty"></li>
        <!-- <li class="itemempty"></li>
        <li class="itemempty"></li> -->
      </ul>
    </div>
    <!-- <div class="goP1">
      <span @click="goProject">返回专题页 ></span>
    </div> -->
    <cfooter></cfooter>
  </div>
</template>
<script>
import cheader from '@/components/cheader/cheader'
import cfooter from '@/components/cfooter/cfooter'
import api from '@/common/js/api'
export default {
  data () {
    return {
      pageIndex: 0,
      bg: require('@/common/img/bg.png'),
      ball: '',
      project: 0,
      blc: '',
      bannerBg: [
        '#59bed9',
        '#d2964f',
        '#57a9d5',
        '#2e9a9a'
      ],
      titleArr: [
        // 专题一
        [
          {
            title1: '以笔为旗, 书写大爱',
            title2: '书法作品大合集'
          },
          {
            title1: '丹青妙手，聚暖生春',
            title2: '平面绘画作品大合集'
          },
          {
            title1: '字字珠玑，心灯长明',
            title2: '诗词作品'
          },
          {
            title1: '匠心独具，心系疫情',
            title2: '原创MV作品大合集'
          }
        ],
        // 专题二
        [
          {
            title1: '桃李不言，大爱交大',
            title2: ''
          },
          {
            title1: '战疫一线，唱响基层',
            title2: ''
          },
          {
            title1: '青春战疫，百炼成钢',
            title2: ''
          }
        ],
        // 专题三
        [
          {
            title1: '康康战疫记',
            title2: ''
          },
          {
            title1: '科技战疫',
            title2: ''
          },
          {
            title1: '建言献策',
            title2: ''
          },
          {
            title1: '科普知识',
            title2: ''
          }
        ],
        // 专题四
        [
          {
            title1: '躬先表率',
            title2: '优秀共产党员'
          },
          {
            title1: '医者仁心',
            title2: '照片集锦'
          },
          {
            title1: '心得感悟',
            title2: '手稿集锦'
          },
          {
            title1: '感动你我',
            title2: '专题短片'
          }
        ]
      ],
      postType: 0,
      dataArr: [],
      schoolArr: [],
      schoolActive: ''
    }
  },
  created () {
    this.project = this.$route.query.project
    this.blc = this.$route.query.blc
    this.postType = this.$route.query.postType
    this.postId = this.$route.query.postId
    api.articleList(this.postType, this.postId).then(res => {
      if (res.data.result === '0') {
        this.dataArr = res.data.data.list
        if (res.data.data.colleges) {
          this.schoolArr = res.data.data.colleges
        }
      }
    })
  },
  mounted () {
    this.ball = require('../../common/img/ball' + (parseInt(this.project) + 1) + '.png')
  },
  updated () {
    let wH = window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight
    let dom = document.querySelector('.list')
    if (dom) {
      document.querySelector('.list').style.minHeight = wH - 544 + 'px'
    }
  },
  methods: {
    goProject () {
      this.$router.push({
        name: 'project' + (parseInt(this.project) + 1)
      })
    },
    jump (e) {
      let did = e.target.dataset.did
      this.did = did
      this.goToDetail(this.project, this.blc, this.did)
    },
    chooseSchool (e) {
      let lid = e.target.dataset.lid
      if (lid === '0') {
        this.schoolActive = 0
        api.articleList(23).then(res => {
          if (res.data.result === '0') {
            this.dataArr = res.data.data.list
          }
        })
      } else {
        this.schoolActive = parseInt(e.target.dataset.index) + 1
        api.chooseSchool(23, lid).then(res => {
          if (res.data.result === '0') {
            this.dataArr = res.data.data.list
          }
        })
      }
    },
    // 去文章详情页 (专题几，第几个模块, 后端参数id, 后端参数id)
    goToDetail (project, blc, did) {
      this.$router.push({
        name: 'projectDetail',
        query: {
          project: project,
          blc: blc,
          did: did
        }
      })
    }
  },
  components: {
    cheader,
    cfooter
  }
}
</script>
<style lang="scss" scoped>
  $tjBlue: #59bed9;
  .project1List {
    // background-color: #59bed9;
    padding-bottom: 40px;
    .banner {
      height: 250px;
      background: center center no-repeat;
      // background-color: #000;
      width: 100%;
      overflow: hidden;
      position: relative;
      z-index: 1;
      .bg {
        display: block;
        width: 375px;
        height: 229px;
        position: absolute;
        top: 0;
        left: 50%;
        z-index: 2;
        margin-left: -187px;
      }
      .color {
        width: 100%;
        height: 250px;
        position: absolute;
        top: 0;
        left: 0;
        z-index: 1;
        // opacity: .5;
      }
      .content {
        // background: #ccc;
        width: 100%;
        height: 100%;
        margin: 0 auto;
        position: relative;
        z-index: 3;
        text-align: center;
        padding-top: 100px;
        .p1-title {
          // position: absolute;
          // left: 0px;
          // bottom: 40px;
          .t {
            height: 30px;
            position: relative;
            display: inline-block;
            img {
              position: absolute;
              left: 0;
              top: 0;
              width: 29px;
              height: 29px;
            }
            h2 {
              font-size: 17px;
              color: #fff;
              position: relative;
              top: 11px;
              margin-left: 3px;
              font-weight: bold;
            }
            i {
              width: 5px;
              height: 5px;
              position: absolute;
              right: -3px;
              bottom: 0px;
              background-color: #ffe75f;
            }
          }
          .b {
            margin-top: 10px;
            display: flex;
            justify-content: space-between;
            position: relative;
            h3 {
              font-size: 14px;
              color: #fff;
              position: relative;
              z-index: 3;
              width: 100%;
            }
            i {
              color: #fff;
              font-size: 20px;
              font-style: normal;
              cursor: pointer;
            }
          }
        }
        .goProject {
          cursor: pointer;
          height: 20px;
          line-height: 20px;
          // background-color: red;
          color: #fff;
          position: absolute;
          bottom: 49px;
          right: 12px;
        }
      }
    }
    .tab {
      width: 1100px;
      margin: 20px auto;
      ul {
        font-size: 0;
        li {
          display: inline-block;
          height: 28px;
          line-height: 28px;
          min-width: 120px;
          border: 1px solid #919191;
          border-radius: 5px;
          text-align: center;
          font-size: 16px;
          cursor: pointer;
          margin-bottom: 10px;
          box-sizing: border-box;
          padding: 0 20px;
          margin-right: 10px;
          &.active {
            color: #a76d23;
            border: 1px solid #a26416;
            background-color: #ffdfb6;
          }
          &::selection {
            background:transparent;
          }
        }
      }
    }
    .list {
      width: 325px;
      margin: -78px auto 10px;
      min-height: 384px;
      position: relative;
      z-index: 2;
      ul {
        width: 100%;
        display: flex;
        justify-content: space-between;
        flex-wrap: wrap;
        &::after{ //重要
            flex: auto;
            content: "";
        }
        li {
          width: 157px;
          height: 135px;
          border-radius: 10px;
          overflow: hidden;
          margin-bottom: 20px;
          border: 1px solid #ccc;
          box-sizing: border-box;
          cursor: pointer;
          transition: all .3s;
          &:hover {
            box-shadow: 0 0 30px #ccc;
          }
          &.itemempty {
            height: 0;
            width: 262px;
            border: 0 none;
          }
          .t {
            box-sizing: border-box;
            height: 100px;
            width: 100%;
            background: #ccc center no-repeat;
            background-size: cover;
            position: relative;
            border-bottom: 1px solid #ccc;
            .cover {
              height: 80px;
              width: 100%;
              background-image: linear-gradient(transparent, #000);
              position: absolute;
              left: 0;
              bottom: 0;
              h3 {
                position: absolute;
                left: 12px;
                bottom: 12px;
                color: #fff;
                font-size: 17px;
              }
            }
            .videoCover {
              height: 100px;
              width: 100%;
              // background-image: linear-gradient(transparent, #000);
              background-color: rgba($color: #000000, $alpha: .5);
              position: absolute;
              left: 0;
              bottom: 0;
              .icon {
                font-size: 50px;
                position: absolute;
                left: 50%;
                top: 50%;
                margin-left: -25px;
                margin-top: -25px;
                color: #fff;
              }
            }
          }
          .b {
            box-sizing: border-box;
            height: 35px;
            line-height: 32px;
            background-color: #fff;
            box-sizing: border-box;
            padding: 0 12px;
            // display: none;
            h4 {
              font-size: 14px;
              color: #444;
              // line-height: 20px;
              white-space: pre-wrap;
            }
          }
        }
      }
    }
    .goP1 {
      width: 1100px;
      overflow: hidden;
      margin: 30px auto 30px;
      height: 20px;
      // background-color: #ccc;
      position: relative;
      span {
        height: 20px;
        line-height: 20px;
        font-size: 20px;
        color: #444;
        position: absolute;
        right: 0;
        cursor: pointer;
      }
    }
    .cfooter {
      border-top: 1px solid #aaa;
      background-color: #fff;
      width: 100%;
      position: fixed;
      left: 0;
      bottom: 0;
      z-index: 999;
    }
    .cfooter >>> div {
      color: #505050;
    }
  }
</style>
